From 795ef5b4e347f003e9e8cf21bdeb4dbe53bda617 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Fri, 20 Mar 2020 23:56:41 -0400 Subject: [PATCH] textbuffer: Parse overline and hyphenation attributes When inserting Pango markup into a text buffer, translate Pango attributes for overlines and hyphenation control into the corresponding text tag properties. --- gtk/gtktextbuffer.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/gtk/gtktextbuffer.c b/gtk/gtktextbuffer.c index c24bc61df4..610d79da10 100644 --- a/gtk/gtktextbuffer.c +++ b/gtk/gtktextbuffer.c @@ -4758,6 +4758,10 @@ get_tag_for_attributes (PangoAttrIterator *iter) if (attr) g_object_set (tag, "underline", ((PangoAttrInt*)attr)->value, NULL); + attr = pango_attr_iterator_get (iter, PANGO_ATTR_OVERLINE); + if (attr) + g_object_set (tag, "overline", ((PangoAttrInt*)attr)->value, NULL); + attr = pango_attr_iterator_get (iter, PANGO_ATTR_UNDERLINE_COLOR); if (attr) { @@ -4772,6 +4776,20 @@ get_tag_for_attributes (PangoAttrIterator *iter) g_object_set (tag, "underline-rgba", &rgba, NULL); } + attr = pango_attr_iterator_get (iter, PANGO_ATTR_OVERLINE_COLOR); + if (attr) + { + PangoColor *color; + GdkRGBA rgba; + + color = &((PangoAttrColor*)attr)->color; + rgba.red = color->red / 65535.; + rgba.green = color->green / 65535.; + rgba.blue = color->blue / 65535.; + rgba.alpha = 1.; + g_object_set (tag, "overline-rgba", &rgba, NULL); + } + attr = pango_attr_iterator_get (iter, PANGO_ATTR_STRIKETHROUGH); if (attr) g_object_set (tag, "strikethrough", (gboolean) (((PangoAttrInt*)attr)->value != 0), NULL); @@ -4810,6 +4828,18 @@ get_tag_for_attributes (PangoAttrIterator *iter) if (attr) g_object_set (tag, "font-features", ((PangoAttrString*)attr)->value, NULL); + attr = pango_attr_iterator_get (iter, PANGO_ATTR_ALLOW_BREAKS); + if (attr) + g_object_set (tag, "allow-breaks", ((PangoAttrInt*)attr)->value, NULL); + + attr = pango_attr_iterator_get (iter, PANGO_ATTR_SHOW); + if (attr) + g_object_set (tag, "show-spaces", ((PangoAttrInt*)attr)->value, NULL); + + attr = pango_attr_iterator_get (iter, PANGO_ATTR_INSERT_HYPHENS); + if (attr) + g_object_set (tag, "insert-hyphens", ((PangoAttrInt*)attr)->value, NULL); + return tag; } -- 2.30.2